<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width= , initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .active {
        color: red;
    }
</style>
<body>
    <div id="app">
       
       <ul>
        <li v-for="(item , index) in movies"
            :class="{active: currentIndex === index}"
            @click="liClick(index)">
            {{index}}=={{item}}</li>
       </ul>
       
    </div>
    <script src="../js/vue.js"></script>
    <script>
        // 小问题： 切换时input框里的数据不会消失  vue底层元素复用，为了性能
         const app = new Vue({
            el: '#app',    
            data: {    
                movies: ['海王','海贼王','加勒比海盗','海尔兄弟'],
                currentIndex: 0
            },
            methods: {
                liClick(index) {
                    this.currentIndex = index;
                }
            }
        })
    </script>
</body>
</html>